#include <iostream>

using namespace std;

int maxsum(int n,int m,int *a){
    if(n<m || m<1)
        return 0;
    int *b = new int[n+1];
    int *c = new int[n+1];
    for(int i=0; i<=n; i++)
        c[i] = 0;
    b[0] = 0;
    for(int i=1; i<=m; i++){
        b[i] = b[i-1] + a[i];
        c[i-1] = b[i];
        int Max = b[i];
        for(int j=i+1; j<=n+i-m; j++){
            b[j] = b[j-1]>c[j-1] ? b[j-1]+a[j] : c[j-1]+a[j];
            c[j-1] = Max;
            Max = max(Max,b[j]);
        }
        c[n+i-m] =Max;
    }
    int sum = 0;
    for(int j=m; j<=n; j++)s
        sum = max(sum,b[j]);
    return sum;
}

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n+1001];
    for(int i=1; i<=n; i++)
        cin>>a[i];
    cout<<maxsum(n,m,a);
    return 0;
}
